/**
 * 
 */
package com.cbank.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cbank.dao.DistinctPhoneDao;
import com.cbank.domain.DistinctPhone;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:cBank
 * </p>
 * <p>
 * Contact: 1027448479@qq.com
 * </p>
 * 
 * @author Ag
 * @date 2016年12月13日
 */
@Service
public class DistinctPhoneService {
	@Autowired
	private DistinctPhoneDao dao;

	public int save(DistinctPhone distinctPhone) {
		String phone = distinctPhone.getPhone();
		int count = dao.getPhoneCount(phone);
		if (count == 0) {//电话号码不重复
			dao.insert(distinctPhone);
			System.out.println("不重复---"+phone);
			return 0;
		}
		System.out.println("重复---"+phone);
		return -1;
	}

	public DistinctPhone getById(Long id) {
		DistinctPhone c = dao.getById(id);
		return c;
	}

	public List<DistinctPhone> getList(Integer index, Integer pagerSize) {
		return this.dao.getPage(index, pagerSize);
	}

	public Integer getCount() {
		return dao.getCount();
	}
	public void updateInvalid(String phone){
		dao.updateInvalid(phone);
	}
}
